/***********************************************
 * Title:       PracticeCourseScheduleService.java
 * Description: PracticeCourseScheduleService.java
 * Author:      NiDeveloper
 * Create Date: 2010-4-5
 * CopyRight:   CopyRight(c)@2009
 * Company:     TJUSCS
 * Version:     1.0
 ***********************************************
 */
package edu.tju.runtimeConfig;

/**
 * @author NiDeveloper
 *
 */
public class PracticeCourseScheduleService implements ConfigService
{        
        public final static String UNSCHEDULED = "unscheduled";
        public final static String CONFIRMED = "confirmed";
        public final static String TEACHERSCHEDULED = "teacherScheduled";
        public final static String CURRICULUMSCHEDULED = "curriculumScheduled";
        
        private final static String DB_KEY = "practiceCourseScheduledState";
        private final static String DEFAULT_VALUE = UNSCHEDULED;
        
        private static PracticeCourseScheduleService _instance;
        static
        {
                _instance = new PracticeCourseScheduleService();
        }
        
        public static PracticeCourseScheduleService getInstance()
        {
                return _instance;
        }
        
        public void setUnsheduled()
        {
                RuntimeConfigUtil.getInstance().setValue(DB_KEY, UNSCHEDULED);
        }
        
        public void setConfirmed()
        {
                RuntimeConfigUtil.getInstance().setValue(DB_KEY, CONFIRMED);
        }
        
        public void setTercherScheduled()
        {
                RuntimeConfigUtil.getInstance().setValue(DB_KEY, TEACHERSCHEDULED);
        }
        
        public void setCurriculumScheduled()
        {
                RuntimeConfigUtil.getInstance().setValue(DB_KEY, CURRICULUMSCHEDULED);
        }
        
        public String getState()
        {
                try
                {
                        return RuntimeConfigUtil.getInstance().getValue(DB_KEY);
                } catch (NoSuchConfigInfoException e)
                {
                        RuntimeConfigUtil.getInstance().setValue(DB_KEY, DEFAULT_VALUE);
                        return DEFAULT_VALUE;
                }
        }
        
        public boolean isUnscheduled()
        {
                return CourseScheduleService.UNSCHEDULED.equals(getState());
        }
        
        public boolean isConfirmed()
        {
                return CourseScheduleService.CONFIRMED.equals(getState());
        }
        
        public boolean isTeacherScheduled()
        {
                return CourseScheduleService.TEACHERSCHEDULED.equals(getState());
        }
        
        public boolean CurriculumScheduled()
        {
                return CourseScheduleService.CURRICULUMSCHEDULED.equals(getState());
        }

        /* (non-Javadoc)
         * @see edu.tju.runtimeConfig.ConfigService#clearValue(java.lang.String)
         */
      
        public void clearValue(String newTerm)
        {
                setUnsheduled();                
        }
        
        
}
